﻿<UserControl x:Class="MathematicallySafe.HeadCounter.Views.RaiderOverviewView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ViewModels="clr-namespace:MathematicallySafe.HeadCounter.ViewModels">

    <UserControl.Resources>
       
        <DataTemplate x:Key="RaidDropTemplate" DataType="ViewModels:RaidDrop">
            <TextBlock>
                <Hyperlink TextDecorations="None" NavigateUri="{Binding Item.LootUri}" RequestNavigate="HyperlinkOnRequestNavigate">
                    <TextBlock Style="{StaticResource LootHyperlinkStyle}" Text="{Binding Path=Item.Name}">
                        <TextBlock.ToolTip>
                            <ToolTip Content="{Binding Path=Item}" Style="{StaticResource ItemTooltipTemplate}" />
                        </TextBlock.ToolTip>
                    </TextBlock>
                </Hyperlink>
            </TextBlock>
        </DataTemplate>
        
        <DataTemplate x:Key="RaidSummaryTemplate" DataType="ViewModels:RaiderRaidSummary">
            <Grid HorizontalAlignment="Left">
                
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" MinWidth="90" />
                    <ColumnDefinition Width="Auto" MinWidth="180"/>
                    <ColumnDefinition Width="270" />
                </Grid.ColumnDefinitions>
                
                <TextBlock Grid.Column="0" Style="{StaticResource DataTextStyle}" VerticalAlignment="Top"
                           Text="{Binding Path=Date, StringFormat=\{0:ddd\, dd MMM\}}" />
                
                <TextBlock Grid.Column="1" Style="{StaticResource DataTextStyle}" VerticalAlignment="Top"
                           Text="{Binding Path=Location}" />
                
                <ItemsControl Grid.Column="2" Style="{StaticResource WrappingItemsPanel}" VerticalAlignment="Top"
                              ItemsSource="{Binding LootWon}" ItemTemplate="{StaticResource RaidDropTemplate}" 
                              ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
            </Grid>
        </DataTemplate>
        
    </UserControl.Resources>

    <Grid Grid.IsSharedSizeScope="True" HorizontalAlignment="Stretch" Margin="0,0,8,0">

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <GroupBox Grid.Row="0" Header="Details" Style="{StaticResource StandardGroupBox}" HorizontalContentAlignment="Stretch">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="LeftLabel" MinWidth="75"/>
                    <ColumnDefinition Width="*" SharedSizeGroup="LeftData" MinWidth="75"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MiddleLabel" MinWidth="75"/>
                    <ColumnDefinition Width="*" SharedSizeGroup="MiddleData" MinWidth="75"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="RightLabel" MinWidth="75"/>
                    <ColumnDefinition Width="*" SharedSizeGroup="RightData" MinWidth="75"/>
                    <ColumnDefinition Width="50" SharedSizeGroup="RightButton" MinWidth="50"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource ControlLabelStyle}" Text="Name:" />    
                <TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource DataTextStyle}" Text="{Binding Path=Name}" />    
                
                <TextBlock Grid.Row="0" Grid.Column="2" Style="{StaticResource ControlLabelStyle}" Text="Class:" />    
                <TextBlock Grid.Row="0" Grid.Column="3" Style="{StaticResource DataTextStyle}" Text="{Binding Path=Class, Converter={StaticResource EnumDescriptionConverter}}" />    
                
                <TextBlock Grid.Row="0" Grid.Column="4" Style="{StaticResource ControlLabelStyle}" Text="Raiding Since:" />    
                <TextBlock Grid.Row="0" Grid.Column="5" Style="{StaticResource DataTextStyle}" Text="{Binding Path=Joined, StringFormat=\{0:dd MMM yy\}}" />

                <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource ControlLabelStyle}" Text="Alts:" VerticalAlignment="Top" />
                <TextBlock Grid.Row="1" Grid.Column="1" MaxWidth="150" Grid.ColumnSpan="4" Style="{StaticResource DataTextStyle}" Text="{Binding Path=AltList}" TextWrapping="Wrap" VerticalAlignment="Top"/>

                <TextBlock Grid.Row="1" Grid.Column="4" Style="{StaticResource ControlLabelStyle}" Text="Last Raid:" />
                <TextBlock Grid.Row="1" Grid.Column="5" Style="{StaticResource DataTextStyle}" Text="{Binding Path=LastRaidDate, StringFormat=\{0:dd MMM yy\}}" />
                
            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="1" Header="Attendance" Style="{StaticResource StandardGroupBox}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="LeftLabel" MinWidth="75"/>
                    <ColumnDefinition Width="*" SharedSizeGroup="LeftData" MinWidth="90"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MiddleLabel" MinWidth="75"/>
                    <ColumnDefinition Width="*" SharedSizeGroup="MiddleData" MinWidth="90"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="RightLabel" MinWidth="75"/>
                    <ColumnDefinition Width="*" SharedSizeGroup="RightData" MinWidth="90"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource ControlLabelStyle}" 
                           Text="{Binding Source={x:Static ViewModels:RaidersViewModel.ShortPeriodAttendanceLabel}, StringFormat=\{0\}:}">
                    <TextBlock.ToolTip>Attendance % / Attendance including optional %</TextBlock.ToolTip>
                </TextBlock>
                <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center">
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=ShortPeriodAttendance, StringFormat={}{0:0%}}" />
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=ShortPeriodAllAttendance, StringFormat=/ {0:0%}}" />
                </StackPanel>

                <TextBlock Grid.Row="0" Grid.Column="2" Style="{StaticResource ControlLabelStyle}" 
                           Text="{Binding Source={x:Static ViewModels:RaidersViewModel.LongPeriodAttendanceLabel}, StringFormat=\{0\}:}">
                    <TextBlock.ToolTip>Attendance % / Attendance including optional %</TextBlock.ToolTip>
                </TextBlock>
                <StackPanel Grid.Row="0" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Center">
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LongPeriodAttendance, StringFormat={}{0:0%}}" />
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LongPeriodAllAttendance, StringFormat=/ {0:0%}}" />
                </StackPanel>

                <TextBlock Grid.Row="0" Grid.Column="4" Style="{StaticResource ControlLabelStyle}" 
                           Text="Lifetime Att%">
                    <TextBlock.ToolTip>Attendance % / Attendance including optional %</TextBlock.ToolTip>
                </TextBlock>
                <StackPanel Grid.Row="0" Grid.Column="5" Orientation="Horizontal" HorizontalAlignment="Center">
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LifetimeAttendance, StringFormat={}{0:0%}}" />
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LifetimeAllAttendance, StringFormat=/ {0:0%}}" />
                </StackPanel>

            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="2" Header="Loot Metrics" Style="{StaticResource StandardGroupBox}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="75"/>
                    <ColumnDefinition Width="50"/>
                    <ColumnDefinition Width="50"/>
                    <ColumnDefinition Width="75"/>
                    <ColumnDefinition Width="50"/>
                    <ColumnDefinition Width="125"/>
                    <ColumnDefinition Width="75"/>
                    <ColumnDefinition Width="50"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource ControlLabelStyle}" Text="6wk Loot:">
                    <TextBlock.ToolTip>Number of items looted in the last 6 weeks</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=ShortPeriodLootCount}" />

                <TextBlock Grid.Row="0" Grid.Column="2" Style="{StaticResource ControlLabelStyle}" Text="Value:">
                    <TextBlock.ToolTip>Weighted value of loot (weapons count more, etc)</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="0" Grid.Column="3" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=ShortPeriodLootValue, StringFormat={}{0:F2}}" />

                <TextBlock Grid.Row="0" Grid.Column="4" Style="{StaticResource ControlLabelStyle}" Text="Rate:">
                    <TextBlock.ToolTip>Number of items per raid (flat / weighted)</TextBlock.ToolTip>
                </TextBlock>
                <StackPanel Grid.Row="0" Grid.Column="5" Orientation="Horizontal">
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=ShortPeriodLootRate, StringFormat={}{0:F2}}" />
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=ShortPeriodWeightedLootRate, StringFormat=/ {0:F2}}" />
                </StackPanel>

                <TextBlock Grid.Row="0" Grid.Column="6" Style="{StaticResource ControlLabelStyle}" Text="Priority:">
                    <TextBlock.ToolTip>Loot priority based on last 6 weeks of looting</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="0" Grid.Column="7" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=ShortPeriodRelativeLootPriority, StringFormat={}{0:F2}}" />
                
                <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource ControlLabelStyle}" Text="12wk Loot:">
                    <TextBlock.ToolTip>Number of items looted in the last 12 weeks</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LongPeriodLootCount}" />

                <TextBlock Grid.Row="1" Grid.Column="2" Style="{StaticResource ControlLabelStyle}" Text="Value:">
                    <TextBlock.ToolTip>Weighted value of loot (weapons count more, etc)</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="1" Grid.Column="3" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LongPeriodLootValue, StringFormat={}{0:F2}}" />

                <TextBlock Grid.Row="1" Grid.Column="4" Style="{StaticResource ControlLabelStyle}" Text="Rate:">
                    <TextBlock.ToolTip>Number of items per raid (flat/weighted) for 12 weeks</TextBlock.ToolTip>
                </TextBlock>
                <StackPanel Grid.Row="1" Grid.Column="5" Orientation="Horizontal" Grid.ColumnSpan="2">
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LongPeriodLootRate, StringFormat={}{0:F2}}" />
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LongPeriodWeightedLootRate, StringFormat=/ {0:F2}}" />
                </StackPanel>

                <TextBlock Grid.Row="1" Grid.Column="6" Style="{StaticResource ControlLabelStyle}" Text="Priority:">
                    <TextBlock.ToolTip>Loot priority based on last 12 weeks of looting</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="1" Grid.Column="7" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LongPeriodRelativeLootPriority, StringFormat={}{0:F2}}" />

                <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource ControlLabelStyle}" Text="Total Loot:">
                    <TextBlock.ToolTip>Number of items looted in total</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LifetimeLootCount}" />

                <TextBlock Grid.Row="2" Grid.Column="2" Style="{StaticResource ControlLabelStyle}" Text="Value:">
                    <TextBlock.ToolTip>Weighted value of loot (weapons count more, etc)</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="2" Grid.Column="3" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LifetimeLootValue, StringFormat={}{0:F2}}" />

                <TextBlock Grid.Row="2" Grid.Column="4" Style="{StaticResource ControlLabelStyle}" Text="Rate:">
                    <TextBlock.ToolTip>Number of items per raid (flat/weighted) for 12 weeks</TextBlock.ToolTip>
                </TextBlock>
                <StackPanel Grid.Row="2" Grid.Column="5" Orientation="Horizontal" Grid.ColumnSpan="2">
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LifetimeLootRate, StringFormat={}{0:F2}}" />
                    <TextBlock Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LifetimeWeightedLootRate, StringFormat=/ {0:F2}}" />
                </StackPanel>

                <TextBlock Grid.Row="2" Grid.Column="6" Style="{StaticResource ControlLabelStyle}" Text="Priority:">
                    <TextBlock.ToolTip>Loot priority based on all looting</TextBlock.ToolTip>
                </TextBlock>
                <TextBlock Grid.Row="2" Grid.Column="7" Style="{StaticResource NumericDataTextStyle}" Text="{Binding Path=LifetimeRelativeLootPriority, StringFormat={}{0:F2}}" />

            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="3" Header="Recent Raids" Style="{StaticResource StandardGroupBox}">
            <ScrollViewer VerticalScrollBarVisibility="Auto">
                <ItemsControl ItemTemplate="{StaticResource RaidSummaryTemplate}" ItemsSource="{Binding Path=RecentRaids}" />    
            </ScrollViewer>
        </GroupBox>

    </Grid>

</UserControl>
